package net.diaowen.dwsurvey.dao.impl;

import net.diaowen.common.dao.BaseDaoImpl;
import net.diaowen.dwsurvey.dao.FindDictDao;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class FindDictDaoImpl extends BaseDaoImpl implements FindDictDao {
    @Override
    public List<Map<String,String>> finddict(String id) throws Exception{
        try{
            String sql="select dict_id,item_text,item_value,sort_order from t_sys_dict_item where dict_id =?";
            List<Object[]> list=this.getSession().createSQLQuery(sql).setParameter(0,id).list();
//            Iterator iterator=list.iterator();
//            while (iterator.hasNext()){
//                System.out.println(iterator.next());
//            }
            List<Map<String,String>> result=new ArrayList();
            for (Object[] list1:list) {
                Map<String,String> map=new HashMap<>();

                String Dict_id=list1[0].toString();
                String Item_text=list1[1].toString();
                String Item_value=list1[2].toString();
                String Sort_order=list1[3].toString();
                map.put("Dict_id",Dict_id);
                map.put("Item_text",Item_text);
                map.put("Item_value",Item_value);
                map.put("Sort_order",Sort_order);
                result.add(map);

            }
            return result;
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }
}
